// components/goods-list/goods-list.js
Component({
  // 组件的属性列表
  properties: {
    title: {
      type: String,
      value: ''
    },
    goodsList: {
      type: Array,
      value: []
    }
  },

  // 组件的初始数据
  data: {
    leftList: [],
    rightList: []
  },

  // 组件的方法列表
  methods: {
    handleCheckMore() {
      wx.navigateTo({
        url: '/modules/goodsModule/pages/goods-list/goods-list'
      })
    },
    getLeftAndRightList() {
      const { goodsList } = this.properties
      let { leftList, rightList } = this.data
      if (goodsList.length > 0) {
        leftList = goodsList.filter((item, index) => index % 2 === 0)
        rightList = goodsList.filter((item, index) => index % 2 !== 0)
        this.setData({
          leftList,
          rightList
        })
      }
    }
  },
  attached() {
    this.getLeftAndRightList()
  }
})
